import request from '@/utils/request'
import { encrypt } from '@/utils/jsencrypt'

// 登录方法
export function login(username, password, code, uuid) {
  console.log(username, password);
  password = encrypt(password);
  const data = {
    username,
    password,
    code,
    uuid
  }
  
  return request({
    url: '/login',
    method: 'post',
    data: data
  })
}

// 获取用户详细信息
export function getInfo() {
  const res = {
    msg: "操作成功",
    code: 200,
    permissions: ["*:*:*"],
    roles: ["admin"],
    user: {
      searchValue: null,
      createBy: "admin",
      createTime: "2020-11-05 16:22:02",
      updateBy: null,
      updateTime: null,
      remark: "管理员",
      params: {},
      userId: 1,
      deptId: 103,
      userName: "admin",
      nickName: "管理员",
      email: "234132@qq.com",
      phonenumber: "15888888888",
      sex: "1",
      avatar: "",
      salt: null,
      status: "0",
      delFlag: "0",
      loginIp: "127.0.0.1",
      loginDate: "2020-11-05 16:22",
      dept: {
        searchValue: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        params: {},
        deptId: 103,
        parentId: 111,
        ancestors: null,
        deptName: "学生处",
        orderNum: "1",
        leader: "若依",
        phone: null,
        email: null,
        status: "0",
        delFlag: null,
        parentName: null,
        children: [],
      },
      roles: [
        {
          searchValue: null,
          createBy: null,
          createTime: null,
          updateBy: null,
          updateTime: null,
          remark: null,
          params: {},
          roleId: 1,
          roleName: "超级管理员",
          roleKey: "admin",
          roleSort: "1",
          dataScope: "1",
          menuCheckStrictly: false,
          deptCheckStrictly: false,
          status: "0",
          delFlag: null,
          flag: false,
          menuIds: null,
          deptIds: null,
          admin: true,
        },
      ],
      roleIds: null,
      postIds: null,
      admin: true,
    },
  };
  return new Promise((resolve, reject) => {
    resolve(res)
  })
  // return request({
  //   url: '/getInfo',
  //   method: 'get'
  // })
}

// 退出方法
export function logout() {
  return request({
    url: '/logout',
    method: 'post'
  })
}

// 获取验证码
export function getCodeImg() {
  return request({
    url: '/captchaImage',
    method: 'get'
  })
}